from flask import Blueprint
from utils.common import response_other
import os
from . import route_func, task_route_func

static_folder = os.path.dirname(__file__) + '/static'
bp = Blueprint('admin', __name__, static_folder=static_folder, url_prefix='/admin')

# 蓝图请求钩子,检查用户是否为管理员
bp.before_request(route_func.check_user_is_admin)
# 释放资源
bp.after_request(route_func.after_request_func)
# 判断是否为管理员
bp.add_url_rule('/', view_func=route_func.index, methods=['GET'])
# 首页
bp.add_url_rule('/index_channel', view_func=route_func.index_channel, methods=['GET', 'POST', 'DELETE', 'PUT'])
# 书
bp.add_url_rule('/book', view_func=route_func.book, methods=['GET', 'POST', 'DELETE', 'PUT'])
# 任务
bp.add_url_rule('/task', view_func=task_route_func.task, methods=['GET', 'POST', 'DELETE', 'PUT'])
# 任务函数
bp.add_url_rule('/task_func_list', view_func=task_route_func.get_task_func_list, methods=['GET'])

bp.add_url_rule('/book_detail/<int:id>',view_func=route_func.book_detail,methods=['GET'])